/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.bits;

import info.peigen.hotpot.component.gateway.dianlan.bits.base.BitParserBase;
import info.peigen.hotpot.component.gateway.dianlan.protocol.passive.DianlanBatteryInsulationResistanceInfo;

/**
 * <b>(DianlanBatteryTemperatureInfoReasonBits)</b>
 * <p>
 * 电池绝缘电阻信息-解析
 *
 * @author LiDaHai
 * @version 1.0.0
 * @since 2023/1/12
 */
public class DianlanBatteryInsulationResistanceInfoReasonBits extends BitParserBase {

    public DianlanBatteryInsulationResistanceInfo parseReason(String hexString) {
        String[]                               hexStrArray = hexStrToArray(hexString);
        DianlanBatteryInsulationResistanceInfo info        = DianlanBatteryInsulationResistanceInfo.builder().build();
        info.setBatterySupplier(parseInt(hexStrArray[0]) + "");
        info.setBatteryType(parseInt(hexStrArray[1]) + "");
        info.setTotalVoltageUpperLimit(4 * parseInt(hexStrArray[2]));
        info.setTotalVoltageLowerLimit(4 * parseInt(hexStrArray[3]));
        info.setInsulationResistance(parseInt(hexStrArray[5] + hexStrArray[4]));
        info.setHvPositiveInsulationResistance(10 * parseInt(hexStrArray[6]));
        info.setHvNegativeInsulationResistance(10 * parseInt(hexStrArray[7]));
        return info;
    }

}